
<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
      <title>1.5.&nbsp;RedHat Linux 上的 Python </title>
      <link rel="stylesheet" href="../diveintopython.css" type="text/css">
      <link rev="made" href="mailto:f8dy@diveintopython.org">
      <meta name="generator" content="DocBook XSL Stylesheets V1.52.2">
      <meta name="keywords" content="Python, Dive Into Python, tutorial, object-oriented, programming, documentation, book, free">
      <meta name="description" content="Python from novice to pro">
      <link rel="home" href="../toc/index.html" title="Dive Into Python">
      <link rel="up" href="index.html" title="第&nbsp;1&nbsp;章&nbsp;安装 Python">
      <link rel="previous" href="macos9.html" title="1.4.&nbsp;Mac OS 9 上的 Python ">
      <link rel="next" href="debian.html" title="1.6.&nbsp;Debian GNU/Linux 上的 Python ">
   </head>
   <body>
      <table id="Header" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
         <tr>
            <td id="breadcrumb" colspan="5" align="left" valign="top">导航：<a href="../index.html">起始页</a>&nbsp;&gt;&nbsp;<a href="../toc/index.html">Dive Into Python</a>&nbsp;&gt;&nbsp;<a href="index.html">安装 Python</a>&nbsp;&gt;&nbsp;<span class="thispage">RedHat Linux 上的 Python </span></td>
            <td id="navigation" align="right" valign="top">&nbsp;&nbsp;&nbsp;<a href="macos9.html" title="上一页: “Mac OS 9 上的 Python ”">&lt;&lt;</a>&nbsp;&nbsp;&nbsp;<a href="debian.html" title="下一页: “Debian GNU/Linux 上的 Python ”">&gt;&gt;</a></td>
         </tr>
         <tr>
            <td colspan="3" id="logocontainer">
               <h1 id="logo"><a href="../index.html" accesskey="1">深入 Python :Dive Into Python 中文版</a></h1>
               <p id="tagline">Python 从新手到专家 [Dip_5.4b_CPyUG_Release]</p>
            </td>
            <td colspan="3" align="right">
               <form id="search" method="GET" action="http://www.google.com/custom">
                  <p><label for="q" accesskey="4">Find:&nbsp;</label><input type="text" id="q" name="q" size="20" maxlength="255" value=""> <input type="submit" value="搜索"><input type="hidden" name="domains" value="woodpecker.org.cn/diveintopython"><input type="hidden" name="sitesearch" value="www.woodpecker.org.cn/diveintopython"></p>
               </form>
            </td>
         </tr>
      </table>
      <!--#include virtual="/inc/ads" -->
      <div class="section" lang="zh_cn">
         <div class="titlepage">
            <div>
               <div>
                  <h2 class="title"><a name="install.redhat"></a>1.5.&nbsp;RedHat Linux 上的 <span class="application">Python</span> 
                  </h2>
               </div>
            </div>
            <div></div>
         </div>
         <p>在类 <span class="acronym">UNIX</span> 的操作系统 (如 Linux) 上安装二进制包很容易。预编译好的二进制包对大多数 Linux 发行版是可用的。或者您可以通过源码进行编译。
         </p>
         <div class="abstract">
            <p>在 <a href="http://www.python.org/ftp/python/">http://www.python.org/ftp/python/</a> 选择列出的最新的版本号, 然后选择
               其中的<tt class="filename">rpms/</tt> 目录下载最新的 <span class="application">Python</span> <span class="acronym">RPM</span> 包。
               使用 <span><b class="command">rpm</b></span> 命令进行安装，操作如下所示:
            </p>
         </div>
         <div class="example"><a name="d0e3640"></a><h3 class="title">例&nbsp;1.2.&nbsp;在 RedHat Linux 9 上安装</h3><pre class="screen">
<tt class="prompt">localhost:~$ </tt><span class="userinput">su -</span>
<tt class="prompt">Password: </tt><span class="userinput">[enter your root password]</span>
<tt class="prompt">[root@localhost root]# </tt><span class="userinput">wget http://python.org/ftp/python/2.3/rpms/redhat-9/python2.3-2.3-5pydotorg.i386.rpm</span>
<span class="computeroutput">Resolving python.org... done.
Connecting to python.org[194.109.137.226]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7,495,111 [application/octet-stream]
...</span>
<tt class="prompt">[root@localhost root]# </tt><span class="userinput">rpm -Uvh python2.3-2.3-5pydotorg.i386.rpm</span>
<span class="computeroutput">Preparing...                ########################################### [100%]
   1:python2.3              ########################################### [100%]</span>
<tt class="prompt">[root@localhost root]# </tt><span class="userinput">python</span>          <a name="install.unix.1.1"></a><img src="../images/callouts/1.png" alt="1" border="0" width="12" height="12">
<span class="computeroutput">Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits", or "license" for more information.</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">[press Ctrl+D to exit]</span>
<tt class="prompt">[root@localhost root]# </tt><span class="userinput">python2.3</span>       <a name="install.unix.1.2"></a><img src="../images/callouts/2.png" alt="2" border="0" width="12" height="12">
<span class="computeroutput">Python 2.3 (#1, Sep 12 2003, 10:53:56)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits", or "license" for more information.</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">[press Ctrl+D to exit]</span>
<tt class="prompt">[root@localhost root]# </tt><span class="userinput">which python2.3</span> <a name="install.unix.1.3"></a><img src="../images/callouts/3.png" alt="3" border="0" width="12" height="12">
<span class="computeroutput">/usr/bin/python2.3</span>
</pre><div class="calloutlist">
               <table border="0" summary="Callout list">
                  <tr>
                     <td width="12" valign="top" align="left"><a href="#install.unix.1.1"><img src="../images/callouts/1.png" alt="1" border="0" width="12" height="12"></a> 
                     </td>
                     <td valign="top" align="left">仅仅键入 <b class="userinput"><tt>python</tt></b> 运行的是老版本的 <span class="application">Python</span> ――它是缺省安装的版本。它不是我们想要的。
                     </td>
                  </tr>
                  <tr>
                     <td width="12" valign="top" align="left"><a href="#install.unix.1.2"><img src="../images/callouts/2.png" alt="2" border="0" width="12" height="12"></a> 
                     </td>
                     <td valign="top" align="left">截止到笔者写作时，新的版本是 <b class="userinput"><tt>python2.3</tt></b>。您可能会需要修改示例脚本的第一行的路径指向新版本。
                     </td>
                  </tr>
                  <tr>
                     <td width="12" valign="top" align="left"><a href="#install.unix.1.3"><img src="../images/callouts/3.png" alt="3" border="0" width="12" height="12"></a> 
                     </td>
                     <td valign="top" align="left">这是我们刚安装的 <span class="application">Python</span> 新版本的全路径。在 <tt class="literal">#!</tt> 行中 (每个脚本的第一行) 使用它来确保脚本运行在最新版的 <span class="application">Python</span> 下，并且确保敲入的是 <b class="userinput"><tt>python2.3</tt></b> 进入交互shell。
                     </td>
                  </tr>
               </table>
            </div>
         </div>
      </div>
      <table class="Footer" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
         <tr>
            <td width="35%" align="left"><br><a class="NavigationArrow" href="macos9.html">&lt;&lt;&nbsp;Mac OS 9 上的 Python </a></td>
            <td width="30%" align="center"><br>&nbsp;<span class="divider">|</span>&nbsp;<a href="index.html#install.choosing" title="1.1.&nbsp;哪一种 Python 适合您？">1</a> <span class="divider">|</span> <a href="windows.html" title="1.2.&nbsp;Windows 上的 Python">2</a> <span class="divider">|</span> <a href="macosx.html" title="1.3.&nbsp;Mac OS X 上的 Python ">3</a> <span class="divider">|</span> <a href="macos9.html" title="1.4.&nbsp;Mac OS 9 上的 Python ">4</a> <span class="divider">|</span> <span class="thispage">5</span> <span class="divider">|</span> <a href="debian.html" title="1.6.&nbsp;Debian GNU/Linux 上的 Python ">6</a> <span class="divider">|</span> <a href="source.html" title="1.7.&nbsp;从源代码安装 Python ">7</a> <span class="divider">|</span> <a href="shell.html" title="1.8.&nbsp;使用 Python 的交互 Shell">8</a> <span class="divider">|</span> <a href="summary.html" title="1.9.&nbsp;小结">9</a>&nbsp;<span class="divider">|</span>&nbsp;
            </td>
            <td width="35%" align="right"><br><a class="NavigationArrow" href="debian.html">Debian GNU/Linux 上的 Python &nbsp;&gt;&gt;</a></td>
         </tr>
         <tr>
            <td colspan="3"><br></td>
         </tr>
      </table>
      <div class="Footer">
         <p class="copyright">Copyright © 2000, 2001, 2002, 2003, 2004 <a href="mailto:mark@diveintopython.org">Mark Pilgrim</a></p>
         <p class="copyright">Copyright © 2001, 2002, 2003, 2004, 2005, 2006, 2007 <a href="mailto:python-cn@googlegroups.com">CPyUG (邮件列表)</a></p>
      </div>
   </body>
</html>